import http from '@/utils/http'

/***
 * @name 注册
 */
export const registerOrLoginApi = (data, path) => {
  return http({
    url: 'member/login/' + path,
    method: 'POST',
    data
  })
}

/***
 * @name 登录
 */
export const loginApi = (data) => {
  return http({
    url: 'member/login/login',
    method: 'POST',
    data
  })
}

/***
 * @name 获取个人信息
 */
export const getUserInfoApi = (data) => {
  return http({
    url: 'member/personal/material',
    method: 'POST',
    data
  })
}

/***
 * @name 修改个人信息
 * @param data.avatar
 * @param data.name
 * @param data.desc
 * @param data.remark
 * @param data.company_info
 */
export const editUserInfoApi = (data) => {
  return http({
    url: 'member/personal/changeInfo',
    method: 'POST',
    data
  })
}

/***
 * @name 修改手机号
 * @param data.mobile
 */
export const editMobileApi = (data) => {
  return http({
    url: 'member/member/change_mobile',
    method: 'POST',
    data
  })
}

/***
 * @name 获取钱包信息
 * @param data.type 默认值 points
 */
export const getWalletApi = (data) => {
  return http({
    url: 'member/personal/wallet_info',
    method: 'POST',
    data
  })
}

/***
 * @name 获取地址列表
 */
export const getAddressListApi = (data) => {
  return http({
    url: 'member/address/get_list',
    method: 'POST',
    data
  })
}

// {{url}}/system/region/getRegion
/***
 * @name 获取地址列表
 * @param data.region 地区上级ID
 */
export const getRegionApi = (data) => {
  return http({
    url: 'system/region/getRegion',
    method: 'POST',
    data
  })
}

/***
 * @name 新增地址
 * @param data.name 收货人姓名
 * @param data.phone 收货人联系方式
 * @param data.region 地区ID
 * @param data.is_default 是否是默认地址1是0否
 * @param data.addr 详细地址
 */
export const addAddressApi = (data) => {
  return http({
    url: 'member/address/add',
    method: 'POST',
    data
  })
}

/***
 * @name 修改地址
 * @param data.id
 * @param data.name 收货人姓名
 * @param data.phone 收货人联系方式
 * @param data.region 地区ID
 * @param data.is_default 是否是默认地址1是0否
 * @param data.addr 详细地址
 */
export const editAddressApi = (data) => {
  return http({
    url: 'member/address/add',
    method: 'POST',
    data
  })
}

/***
 * @name 删除地址
 * @param data.id
 */
export const delAddressApi = (data) => {
  return http({
    url: 'member/address/do_delete',
    method: 'POST',
    data
  })
}

/***
 * @name 我的优惠券
 */
export const myCouponApi = (data) => {
  return http({
    url: 'member/coupon/my_coupon_list',
    method: 'POST',
    data
  })
}

/***
 * @name 领取优惠券
 * @param data.coupon_id
 */
export const receiveCouponApi = (data) => {
  return http({
    url: 'member/coupon/cpupon_receive',
    method: 'POST',
    data
  })
}

/***
 * @name 获取优惠券列表
 */
export const getCouponListApi = (data) => {
  return http({
    url: 'member/coupon/coupon_list',
    method: 'POST',
    data
  })
}

/***
 * @name 公共配置信息
 */
export const configApi = (data) => {
  return http({
    url: '/system/basic/conf',
    method: 'GET',
    data
  })
}

